//
//  StudentListCell.m
//  UI11_Address
//
//  Created by dllo on 15/10/23.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "StudentListCell.h"

@implementation StudentListCell

- (void)dealloc
{
    [_phoneNumber release];
    [_aStudent release];
    [_headImageView release];
    [_nameLabel release];
    [_gender release];
    [super dealloc];
}



#pragma mark -- 自定义cell 第2步:重写初始化方法
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubCiews];
        
    }
    return self;
}

#pragma mark -- 自定义cell 第3步:布局子视图

-(void)createSubCiews
{
    self.headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 15, 80, 80)];
    self.headImageView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.headImageView];
    [_headImageView release];

}

//懒加载
-(UILabel *)nameLabel
{
    if (_nameLabel == nil) {
        self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(100, 10, 185, 30)];
        self.nameLabel.backgroundColor = [UIColor clearColor];
        self.nameLabel.font = [UIFont boldSystemFontOfSize:20];
        [self.contentView addSubview:self.nameLabel];
        [_nameLabel release];
    }
    return _nameLabel;
}

-(UILabel *)phoneNumber
{
    if (_phoneNumber == nil) {
        self.phoneNumber = [[UILabel alloc]initWithFrame:CGRectMake(100, 42, 185, 30)];
        self.phoneNumber.backgroundColor = [UIColor clearColor];
        self.phoneNumber.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.phoneNumber];
        [_phoneNumber release];
    }
    return _phoneNumber;
}



-(UILabel *)gender
{
    if (_gender == nil) {
        self.gender = [[UILabel alloc]initWithFrame:CGRectMake(100, 74, 185, 30)];
        self.gender.backgroundColor = [UIColor clearColor];
        self.gender.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.gender];
        [_gender release];
    }
    return _gender;
}




#pragma mark -- 自定义cell 第7步:重写setter方法传值

-(void)setAStudent:(Students *)aStudent
{
    if (_aStudent != aStudent) {
        [_aStudent release];
        _aStudent = [aStudent retain];
    }
    self.nameLabel.text = self.aStudent.name;
    self.headImageView.image = self.aStudent.myimage;
    self.gender.text = self.aStudent.gender;
    self.phoneNumber.text = self.aStudent.phoneNumber;
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
